home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / sviluppo / svilupp2 / whdload.lha / WHDLoad / src / gods.asm < prev    next >
Assembly Source File  |  1996-07-03  |  4KB  |  218 lines

  1. ;*---------------------------------------------------------------------------
  2. ;  :Program.    gods.asm
  3. ;  :Contents.    Slave for "Gods"
  4. ;  :Author.    BJ
  5. ;  :History.    20.05.96
  6. ;  :Requires.    -
  7. ;  :Copyright.    Public Domain
  8. ;  :Language.    68000 Assembler
  9. ;  :Translator.    Barfly V1.131
  10. ;  :To Do.
  11. ;---------------------------------------------------------------------------*
  12.  
  13.     INCDIR    Includes:
  14.     INCLUDE    whdload.i
  15.  
  16.     OUTPUT    wart:gods/gods.slave
  17.     BOPT    O+ OG+            ;enable optimizing
  18.     BOPT    w4-            ;disable 64k warnings
  19.  
  20. ;======================================================================
  21.  
  22. .base        SLAVE_HEADER        ;ws_Security + ws_ID
  23.         dc.w    1        ;ws_Version
  24.         dc.w    WHDLF_Disk    ;ws_flags
  25.         dc.l    $ff000        ;ws_BaseMemSize            ;$bc000
  26.         dc.l    $f2800        ;ws_ExecInstall
  27.         dc.w    .Start-.base    ;ws_GameLoader
  28.         dc.w    0        ;ws_CurrentDir
  29.         dc.w    0        ;ws_DontCache
  30.  
  31. ;======================================================================
  32. .Start    ;    A0 = resident loader
  33. ;======================================================================
  34.  
  35.         lea    (_resload,pc),a1
  36.         move.l    a0,(a1)            ;save for later using
  37.  
  38.         move.l    #CACRF_EnableI,d0    ;enable instruction cache
  39.         move.l    d0,d1            ;mask
  40.         jsr    (resload_SetCACR,a0)
  41.  
  42.         move.l    #$80400,$2c    ;exp-mem at
  43.         move.b    #1,$1c
  44.         lea    ($1000),a5
  45.         move.l    a5,$84
  46.  
  47.         move.l    #$600,d0    ;offset
  48.         move.l    #$a00,d1    ;size
  49.         moveq    #1,d2        ;disk
  50.         move.l    a5,a0        ;data
  51.         bsr    _LoadDisk
  52.  
  53.         patch    $e2(a5),_loader
  54.         patch    $d6(a5),_1
  55.         jmp    (a5)
  56.  
  57. _1        move.l    #$d200,d0
  58.         patch    $a00+$1bc,_loader
  59.         patch    $a00+$1b0,_2
  60.         rts
  61.  
  62. _2        move.l    #$a280,d0
  63.         patch    $a00+$1db5a,_loader
  64.         rts
  65.  
  66. ;--------------------------------
  67.  
  68. _loader        btst    #0,d3            ;read or write ?
  69.         bne    _savehighs        ;only highscores
  70.  
  71.         moveq    #1,d0
  72.         cmp.l    d0,d1
  73.         bne    .0
  74.         cmp.l    d0,d2
  75.         beq    _loadhighs
  76. .0
  77.         movem.l    d1-d3/a0-a1,-(a7)
  78.  
  79.         cmp.w    #$28a,d2
  80.         bne    .22
  81.         move.w    #$26e,d2    ;let's strip the diskimage a bit (disk1)
  82. .22
  83.         cmp.l    #$7ba80,a0
  84.         bne    .1
  85.         lea    (.disk),a1
  86.         move.w    #2,(a1)        ;from this point only disk 2
  87. .1
  88.         mulu    #512,d1        ;start on disk
  89.         move.l    d1,d0        ;offset
  90.         mulu    #512,d2        ;amount of blocks
  91.         move.l    d2,d1        ;size
  92.         moveq    #0,d2
  93.         move.w    (.disk),d2    ;disk
  94.         bsr    _LoadDisk
  95.  
  96.         bsr    _kinit
  97.         
  98.         movem.l    (a7)+,d1-d3/a0-a1
  99.         moveq    #0,d0
  100.         rts
  101.  
  102. .disk        dc.w    1
  103.  
  104. ;--------------------------------
  105.  
  106. _loadhighs
  107.     IFD wmode
  108.         move.l    #$b4863d88,$60
  109.         move.l    #$5dc,$b04c
  110.         clr.l    $d158
  111.         clr.l    $f6bc
  112.         clr.l    $107f0
  113.     ENDC
  114.         movem.l    d1/a0-a2,-(a7)
  115.         move.l    a0,a1            ;address
  116.         lea    (_savename),a0
  117.         move.l    (_resload),a2
  118.         jsr    (resload_LoadFile,a2)
  119.         tst.l    d0
  120.         bne    .end
  121.         movem.l    (a7),d1/a0-a2
  122.         moveq    #512/4-1,d0
  123. .clr        clr.l    (a0)+
  124.         dbf    d0,.clr
  125. .end        movem.l    (a7)+,d1/a0-a2
  126.         moveq    #0,d0
  127.         rts
  128.  
  129. _savehighs    movem.l    d1-d2/a0-a2,-(a7)
  130.         mulu.w    #512,d2
  131.         move.l    d2,d0
  132.         move.l    a0,a1
  133.         lea    (_savename),a0
  134.         move.l    (_resload),a2
  135.         jsr    (resload_SaveFile,a2)
  136.         movem.l    (a7)+,d1-d2/a0-a2
  137.         moveq    #0,d0
  138.         rts
  139.  
  140. _savename    dc.b    "highs",0
  141.  
  142. ;--------------------------------
  143.  
  144. _kinit        movem.l    a0-a1,-(a7)
  145.         lea    (_keyboard,pc),a1
  146.         cmp.l    $68,a1
  147.         beq    .q
  148.         lea    (_realint68,pc),a0
  149.         move.l    $68,(a0)
  150.         move.l    a1,$68
  151. .q        movem.l    (a7)+,a0-a1
  152.         rts
  153.  
  154. _realint68    dc.l    0
  155.  
  156. _keyboard    move.l    d0,-(a7)
  157.         move.b    $bfec01,d0
  158.         ror.b    #1,d0
  159.         not.b    d0
  160.  
  161. ; RAW-Key-Codes:
  162. ;    ESC    $45
  163. ;    DEL    $46
  164. ;    F1..F10    $50..$59
  165. ;    HELP    $5f
  166.  
  167.         cmp.b    #$58,d0
  168.         bne    .1
  169.         move.l    (a7)+,d0
  170.         bra    _debug            ;coredump & quit
  171. .1
  172.         cmp.b    #$59,d0
  173.         beq    _exit            ;exit
  174.  
  175.         move.l    (a7)+,d0
  176.         move.l    (_realint68),-(a7)    ;enter orginal rou.
  177.         rts
  178.  
  179. ;--------------------------------
  180.  
  181. _resload    dc.l    0        ;address of resident loader
  182.  
  183. ;--------------------------------
  184. ; IN:    d0=offset d1=size d2=disk a0=dest
  185. ; OUT:    d0=success
  186.  
  187. _LoadDisk    movem.l    d0-d2/a0-a2,-(a7)
  188.         move.l    (_resload),a2
  189.         jsr    (resload_DiskLoad,a2)
  190.         tst.l    d0
  191.         beq    .err
  192.         movem.l    (a7)+,d0-d2/a0-a2
  193.         moveq    #-1,d0
  194.         rts
  195.         
  196. .err        move.l    d1,-(a7)
  197.         movem.l    (4,a7),d0-d2/a0-a2
  198.         move.l    d2,(4+5*4,a7)        ;disk number
  199.         move.l    (a7),(4+4*4,a7)        ;doserror
  200.         add.w    #4+4*4,a7
  201.         move.l    #TDREASON_DISKLOAD,-(a7)
  202.         move.l    (_resload),-(a7)
  203.         add.l    #resload_Abort,(a7)
  204.         rts
  205.  
  206. ;--------------------------------
  207.  
  208. _exit        move.l    #TDREASON_OK,-(a7)
  209.         bra    _end
  210. _debug        move.l    #TDREASON_DEBUG,-(a7)
  211. _end        move.l    (_resload,pc),-(a7)
  212.         add.l    #resload_Abort,(a7)
  213.         rts
  214.  
  215. ;======================================================================
  216.  
  217.     END
  218.